package com.qipay.mapper;


import org.apache.commons.lang3.StringUtils;

import java.util.List;

public class CpAccountTradlogSqlProvider extends com.qipay.baas.mapper.CpAccountTradlogSqlProvider {

    public String list(List<Long> cpIdList, String from, String to) {

        return String.format("select * from cp_account_tradlog where cp_id in (%s) and create_time >= '%s' and create_time <= '%s'", StringUtils.join(cpIdList, ","), from, to);
    }

    public String list1(Long cpId, String from, String to,String offset,String size) {
        String cpIdSql = "";
        if(cpId!=null){
            cpIdSql = "and cp_id="+cpId;
        }
        return String.format("select * from cp_account_tradlog where 1=1 %s " +
                "and create_time >= '%s' and create_time <= '%s' " +
                "ORDER BY `id` desc LIMIT %s,%s", cpIdSql, from, to,offset,size);
    }
    public String listGroup(String querysql,String orderBy) {
        return String.format("%s order by "+orderBy+";", querysql);
    }
    public String total(Long cpId, String from, String to) {
        String cpIdSql = "";
        if(cpId!=null){
            cpIdSql = "and cp_id="+cpId;
        }
        return String.format("select  SUM(amount) as amount,COUNT(0) as total from cp_account_tradlog where 1=1 %s " +
                "and create_time >= '%s' and create_time <= '%s' " , cpIdSql, from, to);
    }
}